package com.shuhg.bean
{
	import com.adobe.serialization.json.JSON;
	
	import flash.utils.Dictionary;
	
	import mx.collections.ArrayCollection;
	import mx.utils.UIDUtil;

	public class Book
	{
		//书籍的ID
		private var _id:String;
		//书籍名称
		private var _name:String;
		//书籍作者
		private var _author:String;
		//目录
		private var _index:String;
		//书籍文本内容
		private var  _content:String="";
		//文本宽度
		private var  _contentWidth:Number;
		//文本高度
		private var _contentHeight:Number;
		//文本字体大小
		private var _contentSize:Number;
		//文本字体颜色
		private var _contentColor:uint;
		//文本字体
		private var _contentFont:String;
		//行距离
		private var _leading:Number;
		//字距离
		private var _letterSpacing:Number;
		
		
		public function Book()
		{
		}
		public function initApp(object:Object):Book{
			for(var key:Object in object){
				switch(key){
					case "id":
						this.id=object[key];
						break;
					case "name":
						this.name=object[key];
						break;
					case "index":
						this.index=object[key];
						break;
					case "content":
						this.content=object[key];
						break;
					case "contentColor":
						this.contentColor=object[key];
						break;
					case "contentFont":
						this.contentFont=object[key];
						break;
					case "contentHeight":
						this.contentHeight=object[key];
						break;
					case "contentSize":
						this.contentSize=object[key];
						break;
					case "contentWidth":
						this.contentWidth=object[key];
						break;
					case "leading":
						this.leading=object[key];
						break;
					case "letterSpacing":
						this.letterSpacing=object[key];
						break;
				}
				trace(key,"   ",object[key]);
			}
			return this;
		}
		//书籍的唯一标识
		public function set id(value:String ):void{
			this._id=value;
		}
		public function get id():String{
			return this._id;
		}
		//书籍的名称
		public function set name(value:String ):void{
			this._name=value;
		}
		public function get name():String{
			return this._name;
		}
		//书籍的作者
		public function set author(value:String ):void{
			this._author=value;
		}
		public function get author():String{
			return this._author;
		}
		//书籍的目录
		public function set index(value:String ):void{
			this._index=value;
		}
		public function get index():String{
			return this._index;
		}
		//文本内容
		public function set content(value:String ):void{
			this._content=value;
		}
		public function get content():String{
			return this._content;
		}
		//
		public function set contentWidth(value:Number ):void{
			this._contentWidth=value;
		}
		public function get contentWidth():Number{
			return this._contentWidth;
		}
		//
		public function set contentHeight(value:Number ):void{
			this._contentHeight=value;
		}
		public function get contentHeight():Number{
			return this._contentHeight;
		}
		//
		public function set contentSize(value:Number ):void{
			this._contentSize=value;
		}
		public function get contentSize():Number{
			return this._contentSize;
		}
		//
		public function set contentColor(value:uint ):void{
			this._contentColor=value;
		}
		public function get contentColor():uint{
			return this._contentColor;
		}
		//
		public function set contentFont(value:String ):void{
			this._contentFont=value;
		}
		public function get contentFont():String{
			return this._contentFont;
		}
		//
		public function set leading(value:Number):void{
			this._leading=value;
		}
		public function get leading():Number{
			return _leading;
		}
		//
		public function set letterSpacing(value:Number):void{
			this._letterSpacing=value;
		}
		public function get letterSpacing():Number{
			return _letterSpacing;
		}
		/**
		 * 测试代码
		 * */
		public function test():void{
			var b:Book=new Book();
			b.content="这是书籍文本内容";
			
			var  json:String= JSON.encode(b);
			trace(json);
			//解码
			var book:Object = JSON.decode(json);
			for(var key:String in book.map){
				trace(key +"   "+book.map[key]);
			}
			
			trace(book.content);
			trace(book.edition);
		}
	}
}